import request from "@/utils/request.js";

export const listTask = async () => {
    const res = await request.get('/task/list');
    return res.map(e => ({...e, value: e.id, label: e.name}))
}

export const statusOptions = [
    {value: 1, label: '已接单', type: 'primary'},
    {value: 2, label: '正在前往', type: 'info'},
    {value: 3, label: '物品已取到', type: 'warning'},
    {value: 4, label: '等待确认', type: 'success'},
    {value: 5, label: '完成', type: 'primary'},
]
export const isAbnormalOptions = [
    {value: 0, label: '正常', type: 'primary'},
    {value: 1, label: '异常', type: 'info'},
]

export const fields = [
    {
        prop: 'taskId',
        label: '所属任务',
        type: 'remote-select',
        api: listTask,
        width: 120,
    },
    {
        prop: 'status',
        label: '阶段状态',
        type: 'tag',
        options: statusOptions,
        search: true,
        width: 120,
    },
    {
        prop: 'images',
        label: '阶段图片',
        type: 'image-list',
        width: 120,
    },
    {
        prop: 'description',
        label: '阶段描述',
        type: 'longtext',
        width: 'auto',
    },
    {
        prop: 'isAbnormal',
        label: '是否异常',
        type: 'switch',
        options: isAbnormalOptions,
        search: true,
        width: 170,
    },
    {
        prop: 'createTime',
        label: '阶段创建时间',
        type: 'datetime',
        formHidden: true,
        width: 190,
    }
]